 //单独配置url
 axios.defaults.baseURL = 'http://124.223.14.236:3001/api'
 async function  fn(){
  //渲染省数据
  const provinceStar =  await axios({
      method:'GET',
      url:'/city/province',
      params:{},
    })
    console.log(provinceStar)
    const pros = provinceStar.data.data.map(item =>{
      return`
      <option value="${item.province}">${item.name}</option>
      `
    }).join('')
    document.querySelector('#province').innerHTML = `<option value="">请选择省份</option>` +  pros
    document.querySelector('#province').value = '34'
    //渲染市数据
    const cityStar =  await axios({
      method:'GET',
      url:'/city/city',
      params:{
        provinceCode:'34',
      },
    })
    console.log(cityStar)
    const citys = cityStar.data.data.map(item =>{
      return`
      <option value="${item.city}">${item.name}</option>
      `
    }).join('')
    document.querySelector('#city').innerHTML = `<option value="">请选择城市</option>` +  citys
    document.querySelector('#city').value = '01'
    //渲染区数据
    const areaStar =  await axios({
      method:'GET',
      url:'/city/area',
      params:{
        provinceCode:'34',
        cityCode:'01'
      },
    })
    console.log(areaStar)
    const areas = areaStar.data.data.map(item =>{
      return`
      <option value="${item.area}">${item.name}</option>
      `
    }).join('')
    document.querySelector('#county').innerHTML = `<option value="">请选择区县</option>` +  areas
    document.querySelector('#county').value = '02'
  }
  fn()
  // 注册change事件
    document.querySelector('#province').addEventListener('change',async function(){
      const cityStar =  await axios({
        method:'GET',
        url:'/city/city',
        params:{
          provinceCode:this.value,
        },
      })
      console.log(cityStar)
      const citys = cityStar.data.data.map(item =>{
        return`
        <option value="${item.city}">${item.name}</option>
        `
      }).join('')
      document.querySelector('#city').innerHTML = `<option value="">请选择城市</option>` +  citys
      document.querySelector('#county').innerHTML = `<option value="">请选择区县</option>`
    })
    document.querySelector('#city').addEventListener('change',async function(){
      const areaStar =  await axios({
        method:'GET',
        url:'/city/area',
        params:{
          provinceCode:document.querySelector('#province').value,
          cityCode:this.value
        },
      })
      console.log(areaStar)
      const areas = areaStar.data.data.map(item =>{
        return`
        <option value="${item.area}">${item.name}</option>
        `
      }).join('')
      document.querySelector('#county').innerHTML = `<option value="">请选择区县</option>` +  areas
    })